import logging
from redis import StrictRedis
from datetime import timedelta

# 设置配置类
class Config(object):

    # 设置调试模式
    DEBUG = True

    # 数据库配置
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:mysql@127.0.0.1:3306/information01"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True # 当视图函数结束的时候，会自动提交一次会话

    # redis配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # session配置信息
    SECRET_KEY = "sdsadfgfdg"
    SESSION_TYPE = "redis" #存储类型
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT)
    SESSION_USE_SIGNER = True # 签名存储
    PERMANENT_SESSION_LIFETIME = timedelta(days = 2) # 2天有效 写成秒 seconds = 3600*24*2

    # 默认就是DEBUG模式
    LEVELNAME = logging.DEBUG

# 开发模式配置信息
class DevelopConfig(Config):
    pass

# 生产（线上）模式配置信息
class ProductConfig(Config):
    DEBUG = False
    LEVELNAME = logging.ERROR

# 测试模式配置信息
class TestingConfig(Config):
    TESTING = True


config_dict = {
    "develop":DevelopConfig,
    "product":ProductConfig,
    "testing":TestingConfig
}
